import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/layout'
import HomeIndex from '@/views/homeindex'
import Html from '@/views/htmlindex'
import Css from '@/views/cssindex'
import Js from '@/views/jsindex'
import Node from '@/views/nodeindex'
import UpData from '@/views/updata'
import ErrorPage from '@/views/error'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () =>
      import(/* webpackChunkName: 'login' */ '@/views/login/index')
  },
  {
    path: '/register',
    name: 'register',
    component: () =>
      import(/* webpackChunkName: 'register' */ '@/views/register')
  },
  {
    path: '/publishArticle',
    name: 'publishArticle',
    component: () =>
      import(/* webpackChunkName: 'sendindex' */ '@/views/publishArticle')
  },
  {
    path: '/userpage',
    name: 'userIndex',
    component: () =>
      import(/* webpackChunkName: 'userindex' */ '@/views/userindex')
  },
  {
    path: '/updata',
    name: 'upData',
    component: UpData
  },
  {
    path: '/',
    component: Home,
    children: [
      {
        path: 'home',
        name: 'home',
        component: HomeIndex
      },
      {
        path: 'html',
        name: 'html',
        component: Html
      },
      {
        path: 'css',
        name: 'css',
        component: Css
      },
      {
        path: 'js',
        name: 'js',
        component: Js
      },
      {
        path: 'node',
        name: 'node',
        component: Node
      }
    ]
  },
  {
    path: '*',
    name: 'err-page',
    component: ErrorPage
  }
]

const router = new VueRouter({
  routes
})

export default router
